package week_06;

public class Rob_1_198 {
    public int rob(int[] nums) {
        int n = nums.length;
        int[][] dp = new int[n + 1][2];
        dp[0][0] = 0;
        dp[0][1] = Integer.MIN_VALUE;
        for (int i = 1; i <= n; i++) {
            for (int j = 0; j <= 1; j++) {
                if (j == 0) dp[i][0] = Math.max(dp[i - 1][0], dp[i - 1][1]);
                if (j == 1) dp[i][1] = dp[i - 1][0] + nums[i - 1];
                System.out.println(i + ":" + j + ":" + dp[i][j]);
            }
        }
        return Math.max(dp[n][0], dp[n][-1]);
    }
}
